<template>
  <div>==={{v2}}
    ===son==={{ff}}==={{ss}}
    <input  type="button" @click="say2()" value="btn"/>
       <input  type="button" @click="say3()" value="子向父"/>
  </div>

  <hr/>
  <sun></sun>
</template>

<script>
import {ref,inject} from  'vue'
import sun  from  './sun.vue'
export default {
  inject:['v2'],
  props:['ff'],
  emits:['sshandle'],// 里面是子向父传值的事件名
  components:{sun},
  setup (props,{emit}) {
    const ss=ref('')
    const say2 = () => {
      /* 穿过来的值：只能读不能写==跟v2一样 */
      //  props.ff+=222
      ss.value=props.ff+'2222'
    }
    /* 子向父 */
    const say3 = () => {
      //  v2：this.$emit('事件名',传值)
        // console.log(emit,555);
        emit('sshandle','我是son组件')
    }

    const r=inject('rootMsg')
    console.log(r.value,'son');

    return {say2,ss,say3}
  }
}
</script>

<style lang="scss" scoped>

</style>